package com.stgy.lease.web.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.stgy.lease.common.exception.StgyException;
import com.stgy.lease.common.result.ResultCodeEnum;
import com.stgy.lease.model.domain.DistrictInfo;
import com.stgy.lease.web.api.mapper.DistrictInfoMapper;
import com.stgy.lease.web.api.service.DistrictInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lingx
 * @description 针对表【district_info】的数据库操作Service实现
 * @createDate 2024-08-28 11:00:29
 */
@Service
public class DistrictInfoServiceImpl extends ServiceImpl<DistrictInfoMapper, DistrictInfo>
        implements DistrictInfoService {

    //根据城市id查询区县信息
    @Override
    public List<DistrictInfo> listByCityId(Long id) {
        if (id == null || id < 0) {
            throw new StgyException(ResultCodeEnum.DATA_EXISTS_ERROR);
        }
        LambdaQueryWrapper<DistrictInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DistrictInfo::getCityId, id);
        return this.list(wrapper);
    }
}




